#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#define VERSION "0.5"

#include <QMainWindow>
#include <QFileDialog>
#include "main_area.h"
#include <QPushButton>
#include <QIcon>
#include <QFile>
#include "smart_byte_array.h"
#include <QList>
#include "area.h"
#include <QtDebug>
#include <QMessageBox>
#include <QCoreApplication>
#include <QDesktopServices>
#include <QUrl>

#include <fstream>

namespace Ui
{
    class MainWindowClass;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:

    QWidget * w_pMainWidget;

    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:

    bool parse_data(const SmartByteArray &data);
    bool Open(bool from_buffer = false, bool from_start_file = false);
    bool Open(QString filename);

    QString _filename;
    QStringList _pages;
    int _curPageIndex;
    QByteArray _exchangeBuffer;
    MainArea * _mainarea;

    Ui::MainWindowClass *ui;

    QAction *cursor;
    QAction *addText;
    QAction *addImg;
    QAction *addFile;
    QAction *addPin;
    QAction *addLine;
    QAction *delLine;
    QAction *grid;
    QAction *font;
    QAction *color;
    QAction *zoom_in;
    QAction *zoom_out;
    QAction *nextd;
    QAction *prevd;

    void setTitle(const QString &);

    void resizeEvent(QResizeEvent * QRE);
    void closeEvent(QCloseEvent *);
    void deselectToolbarTools();
    bool Save();

private slots:
    void on_actionAdd_triggered();
    void on_actionCheck_for_updates_triggered();
    void on_actionPaste_triggered();
    void on_actionCopy_triggered();
    void on_actionCut_triggered();
    void on_actionUndo_triggered();
    void on_actionSave_as_triggered();
    void on_actionVersion_triggered();
    void on_actionNew_triggered();
    void on_actionPrint_triggered();
    void on_actionDelete_triggered();
    void on_actionSave_triggered();
    void on_actionOpen_triggered();
    void on_actionSelect_all_triggered();
    void on_actionTerminate_triggered();
    void cursorSlot();
    void textSlot();
    void imageSlot();
    void fileSlot();
    void pinSlot();
    void line_del_Slot();
    void lineSlot();
    void gridSlot();
    void fontSlot();
    void colorSlot();
    void zoominSlot();
    void zoomoutSlot();
    void nextSlot();
    void prevSlot();
};

#endif // MAINWINDOW_H
